export const fileToBase64 = (file: Blob) => {
    return new Promise((resolve, reject) => {
        let reader = new FileReader()
        let result = ''
        reader.readAsDataURL(file)
        reader.onload = () => {
            result = reader.result as string
            result = result.replace(/^data:image\/\w+;base64,/, '')
                .replace('data:application/octet-stream;base64,', '')
        }
        reader.onerror = err => {
            reject(err)
        }
        reader.onloadend = () => {
            resolve(result)
        }
    })
}